package com.micro.ai.template.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.micro.ai.template.entity.AgentMetric;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDate;
import java.util.List;

/**
 * Agent指标Mapper
 *
 * @author micro-ai
 * @since 0.0.1
 */
@Mapper
public interface AgentMetricMapper extends BaseMapper<AgentMetric> {

    /**
     * 根据Agent ID和日期范围查询指标
     */
    @Select("SELECT * FROM agent_metrics WHERE agent_id = #{agentId} " +
            "AND metric_date >= #{startDate} AND metric_date <= #{endDate} ORDER BY metric_date DESC")
    List<AgentMetric> selectByDateRange(
            @Param("agentId") String agentId,
            @Param("startDate") LocalDate startDate,
            @Param("endDate") LocalDate endDate
    );

    /**
     * 查询最近N天的指标
     */
    @Select("SELECT * FROM agent_metrics WHERE agent_id = #{agentId} " +
            "ORDER BY metric_date DESC LIMIT #{days}")
    List<AgentMetric> selectRecentDays(@Param("agentId") String agentId, @Param("days") Integer days);
}

